<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>新闻</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link href="style/bootstrap.css" rel="stylesheet">
<link href="style/bootstrap-theme.css" rel="stylesheet">
<script src="style/jquery-2.1.1.js"></script>
<script src="style/bootstrap.js"></script>
<script src="style/own.js"></script>
<style type="text/css">
    body{  font-family: "微软雅黑";}
    div{margin: 0 auto;}
</style>

<script type="text/javascript">  
$(document).ready(function(){
	
	//更多新闻
	$("#more").click(
		function(){  
        $.ajax({  
        data:"typeid="+$("#typeid").val()+"&page="+$("#page").val(),  
        type:"post",  
        dataType: 'json',  
        url:"<%= path%>/more_news",  
        error:function(data){  
            alert("no more！");  
        },  
        success:function(data){  
        	var nextpage="";
    		var datalist="";
    		var newhtml="";
    		$.each(data,function(key,values){ 
        	    $(values).each(function(){ 
        	    	if(key=='nextpage'){
        	    		nextpage=this; 
        	    		$("#page").val(nextpage);
        	    	}
        	    	if (key=='data') {
        	    		datalist=this;
        			newhtml+=(" <li class=\"list-group-item\">"+"<a target=\"_blank\" href=<%= path%>/new-detail/\""+datalist.id+"\">"+datalist.title +"</a><br/></li>");
					}
        	    });  
        	  });  
    		if (newhtml.length<10) {
       		 $("#new").append(" <li class=\"list-group-item\" style=\"text-align: center;\">"+"没有更多了！！！"+"</li>");
		        $("p").hide();
			}else{
       		 $("#new").append(newhtml+"<br>");
		        $("p").hide();
			}
        }
        
        }); 
        
    });  });
</script>  

</head>
<body>
	<div class="fdiv">
		<div>
			<h2 align="center">新闻</h2>
		</div>
		<div  style="width: 800px;">
			<c:forEach items="${newbean}" var="nbean">
			<li class="list-group-item"><a target="_blank"href="<%= path%>/new-detail/${nbean.id }">${nbean.title }</a></li>
			</c:forEach>
			<div id="new"></div>
		</div>
		<div align="center">
			<nav>
		  <ul class="pager">
		    <li><a href="javascript:void(0)" id="more">加载更多</a></li>
		  </ul>
		</nav>
			<input type="hidden" value="${typeid}" id="typeid">
			<input type="hidden" value="${page+1}" id="page">
		</div>
	</div>
</body>
</html>

